<!--  -->
<template>
  <div>
    <div class="all">
      <div class="musicList">
        <div class="list_wrap">
          <div class="item_wrap">
            <div
            @click="toDetail(item.id)"
              v-for="(item, index) in albumList"
              :key="index"
              class="item"
            >
              <div  class="cover">
                <img :src="item.picUrl" alt="" />
              </div>
              <div class="info">
                <div
                  class="name"
                >
                  {{ item.name }}
                </div>

              </div>
              <div class="album">{{item.artist.name }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="pagination">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="Math.ceil(count / 15) * 10"
        :pager-count="15"
        @current-change="getSearchList"
        :current-page.sync="currentPage"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {
  getSearchList,
  getMusicUrl,
  getSearchSuggest,
} from "util/findMusic.js";

export default {
  name: "",
  data() {
    return {
      albumList: [],
      //最新页
      currentPage: 1,
      count: 0,
    };
  },
  created() {
    this.getSearchList(1);
  },
  methods: {
    async getSearchList(page) {
      // console.log(page);
      let {
        data: { result },
      } = await getSearchList(this.$route.params.data, 15, (page - 1) * 15, 10);
      //   console.log(result)
      this.count = result.albumCount;
      this.albumList = result.albums;
    },
    toDetail(id) {
      this.$router.push("/albumDetail/" + id);
    },
    //返回第一页
    backNumOne() {
      this.currentPage = 1;
    },
  },
};
</script>

<style scoped lang='less'>
.musicList {
  padding: 0 5.25rem;
  .list_wrap {
    // width: 80%;
    .item_wrap {
      .item {
        background-color: #fff;
        height: 40px;
        padding: 10px 0;
        display: flex;
        align-items: center;
        border-radius: 10px;
        .cover {
          margin: 0 10px;
          width: 45px;
          height: 45px;
          border-radius: 5px;
          img {
            width: 100%;
            height: 100%;
            border-radius: 5px;
            box-shadow: 2px 2px 12px 4px rgba(0, 0, 0, 0.1);
          }
        }
        .info {
          margin-left: 10px;
          width: 30%;
          .name {
            width: 100%;
            font-weight: 600;
            font-size: 17px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }
          .creator_name {
            color: #525252;
            font-size: 13px;
          }
          .active_position {
            color: #335eea;
          }
        }
        .album {
          color: #525252;
          width: 30%;
          font-size: 15px;
          margin-left: 20%;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .timer {
          margin-left: 5px;
          color: #525252;
          font-size: 15px;
        }
        .btn {
          width: 20%;
          display: flex;
          align-items: center;
          justify-content: center;
          div {
            display: none;
            margin-left: 20px;
          }
          div:hover {
            transform: scale(1.1);
          }
          .like {
            font-size: 23px;
          }
        }
        .mv {
          width: 8%;
          text-align: right;
          margin-right: 10px;
          &:hover .el-button {
            transform: scale(1.1);
          }
          .el-button {
            background-color: #fff;
            color: rgb(16, 24, 134);
            font-weight: 600;
            border: none;
            border-radius: 5px;
          }
        }
      }
      .item:hover {
        background-color: #f6f6f8;
      }
      .item:hover .btn div {
        display: block;
      }
    }
  }
}
.all ul li {
  padding-left: 20px;
  display: flex;
  height: 80px;
  background: #f9f9f9;
  align-items: center;
}
.all ul li:nth-child(2n) {
  background: #fff;
}
.all ul li:hover {
  background: #f0f1f2;
}
.all ul li .rank {
  width: 30px;
  text-align: center;
  font-size: 20px;
  color: #ddd;
}
.all ul li .img {
  width: 60px;
  height: 60px;
  margin-left: 30px;
  margin-right: 10px;
}
.all ul li .img img {
  width: 100%;
  height: 100%;
  border-radius: 6px;
}
.all ul li .name {
  font-size: 14px;
  flex: 1;
}
.all ul li .alias {
  flex: 1;
  color: #507daf;
  font-size: 12px;
}
.all ul li .score {
  width: 150px;
  font-size: 12px;
  color: rgb(128, 120, 120);
}

.pagination {
  margin-top: 20px;
  text-align: center;
}
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #ec4141;
  color: #fff;
}
::v-deep .el-pagination.is-background .el-pager li:hover {
  color: #ec4141;
}
</style>